<template>
  <div class="components-container">
    <div class="header-form">
        <div class="layui-inline">
          <label  class="layui-form-label">登记状态</label>
          <div class="layui-inline" style="margin-top:-6px">
            <el-radio-group v-model="selectDataEixend.JpmStatusEquals" @change="getData">
              <!-- <el-radio-button  :label="IchValues" class="radio">填报中</el-radio-button> -->
              <el-radio-button  :label="UnIchValue" class="radio">待审核</el-radio-button>
              <el-radio-button  :label="Frozen" class="radio">已冻结</el-radio-button>
              <el-radio-button  :label="UnIchValues" class="radio">已审核</el-radio-button>
              <el-radio-button  :label="cremation" class="radio">已火化</el-radio-button>
              <el-radio-button  :label="cancellation" class="radio">已注销</el-radio-button>
              <el-radio-button  :label="outage" class="radio">已外运</el-radio-button>
            </el-radio-group>
          </div>
       </div>
    <!-- </div>
    <div class="header-form"> -->
       <!-- <el-button type="primary" @click="readDead">读取逝者身份证</el-button> -->
        <div class="layui-inline">
          <label class="layui-form-label">逝者姓名</label>
            <div class="layui-inline">
              <el-input  v-model="selectDataEixend.JPMNAME" placeholder="请输入逝者姓名"></el-input>
            </div>
        </div> 
        <div class="layui-inline">
          <label class="layui-form-label">证件号码</label>
            <div class="layui-inline">
              <el-input  v-model="selectDataEixend.JPMCARDNO" placeholder="请输入证件号码"></el-input>
            </div>
        </div>
        <!-- <div class="layui-inline">
              <label class="layui-form-label">火化日期</label>
              <div class="layui-input-inline">
                <el-date-picker v-date type="date" v-model="selectDataEixend.JpmCremationdateEquals"></el-date-picker>
              </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">户籍地址</label>
            <div class="layui-inline">
              <el-input style="width:220px;" v-model="selectDataEixend.JpmDetailAddressEquals" placeholder="请输入户籍地址"></el-input>
            </div>
        </div>  -->
          <el-button type="primary" @click="getData" :loading="this.$store.state.isloading">搜索</el-button>
          <el-button  @click="btnRepeat" >重置</el-button>
          <!-- <el-button  @click="datas" >数据</el-button> -->
    </div>
    <div>
      <ul class="toolList">
        <li><el-button type="primary" @click="getData">刷新</el-button></li>
        <!-- <li><el-button type="primary" @click="imgprint">图片打印</el-button></li> -->
        <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)" :key="index">
          <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
        </li>              
      </ul>
    </div>
    <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow" :hiddenPageOrder="false"></dataTable>

    <informationRegistrationMain ref="simpleReg" :orderType="order" @refreshData="getData"></informationRegistrationMain>
    <informationRegistrationInfo ref="simpleReginfo" :orderType="order" @refreshData="getData"></informationRegistrationInfo>
    <printmodal ref="printPdf"></printmodal>
    <Appendixlisttwo ref="Upload"></Appendixlisttwo>
    <Appendixlists ref="UploadInfo"></Appendixlists>
    <OperationHistory ref="OperationHistory"></OperationHistory>
  </div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}
.longtext {
  width: 480px;
}
.longertext {
  width: 770px;
}
.sweet-btn {
  margin-top: 20px;
}
.radio {
  margin-top: 9px;
}
</style>
<script>
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import { ORDER } from "@/const/orderConst.js";
import { DATESELECTMODE } from "@/const/const.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";
import { PRINT } from "@/components/Pdf/PDF.js";
import printmodal from "@/components/Pdf/Print";
import informationRegistrationMain from "./informationRegistrationMain";
import informationRegistrationInfo from "./informationRegistrationInfo";
import OperationHistory from "./OperationHistory";
import Appendixlisttwo from "./Appendixlisttwo";
import Appendixlists from "../jointPlatform/Appendixlists";
import openidentitycard from "@/utils/openIdentityCard.js";
import { identitydata }  from "@/utils/openIdentityCard.js";
const IchValues = "A";
const UnIchValue = "B";
const UnIchValues = "C";
const cremation = "D";
const cancellation = "E";
const outage = "F";
const Frozen = "G"
export default {
  name: "informationRegistration",
  mixins: [manage],
  data() {
    return {
      pageWidth: 1200,
      printUrl: null,
      printTitle: null,
      SELFREGISTER: ORDER.SELFREGISTER,
      //户籍所在地
      ctyLists: [],
      ctyInfo: null,
      DateSelectMode: DATESELECTMODE,
      IchValues: IchValues,
      UnIchValue: UnIchValue,
      UnIchValues: UnIchValues,
      Frozen: Frozen,
      cremation: cremation,
      cancellation: cancellation,
      outage: outage,
      selectDataEixend: {
        JpmStatusEquals: null,
        JPMNAME: null,
        JPMCARDNO: null,
        // JpmCremationdateEquals: null,
        // JpmDetailAddressEquals: null
      },
     
      //编码类型
      household: [],
      causList: [],
      codeList: [],
      cause: [],
      cauinfo: [],
      szlx: [],
      ytqx: [],
      ghqx: [],
      xblx: [],
      sfzjlx: [],
      gjlb: [],
      mz: [],
      whcdlx: [],
      hyzklx: [],
      zylx: [],
      zzmmlx: [],
      hjlblx: [],
      hjszdlx: [],
      jmlx: [],
      regData: {
        REGID: null,
        REGPRPID: null,
        REGDATE: null,
        REGTIME: null,
        REGBONETYPE: null,
        REGCAUSA: null,
        REGCAUSASON: null,
        REGDEATHID: null,
        REGREGPROVEUNIT: null,
        REGDEATHADDRESS: null,
        REGYITIQX: null,
        REGGHQX: null,
        REGNAME: null,
        REGSEX: null,
        REGCARDTYPE: null,
        REGCARDNO: null,
        REGBIRTHDATE: null,
        REGNATIONALITYTYPE: null,
        REGNATION: null,
        REGCULTURALDEGREE: null,
        REGMARRIAGE: null,
        REGJOB: null,
        REGPOLITICAL: null,
        REGHOUSEHOLDTYPE: null,
        REGHOUSETYPE: null,
        REGHOUSEHOLD: null,
        REGDETAILADDRESS: null,
        REGDEATHDATE: null,
        REGISKEYPOINT: null,
        REGHANDLERNAME: null,
        REGHANDSEX: null,
        REGHANDLERCARDTYPE: null,
        REGHANDLERCARDNO: null,
        REGHANDLERHOUSEHOLD: null,
        REGHANDLERLINK: null,
        REGRELATION: null,
        REGREMARK: null
      },
      regDataTime: null,
      regTime: null,
      //火化日期
      regCremationDate: null
    };
  },
  methods: {
    // readDead(){
        // console.log('身份证信息');
        // console.log(identitydata);
        // openidentitycard.connects();
    // },
    // datas(){
    //     var cardInfo = [];
    //     console.log('身份证信息');
    //     console.log(identitydata);
          // var index = identitydata.indexOf(":");
          // identitydata.substring(index + 1);
    //     this.cardInfo = identitydata.split(" ");
    //     console.log(this.cardInfo);
          
    // },
    //获取火化登记数据
    getData() {
      let data = {
          JPMCARDNO: this.selectDataEixend.JPMCARDNO,
          JPMNAME: this.selectDataEixend.JPMNAME,
          JpmStatusEquals: this.selectDataEixend.JpmStatusEquals,
          // JpmDetailAddressEquals: this.selectDataEixend.JpmDetailAddressEquals,
        };
      // if(this.selectDataEixend.JpmCremationdateEquals){
      //   datas.JpmCremationdateEquals =  formatDate(this.selectDataEixend.JpmCremationdateEquals, "yyyyMMdd");
      // };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().JointRegistration.QueryJointCre,
        res => {
          this.dataList = res.data.content;
        }
      );
    },
    //获取表头
    getColumns() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetJointRegistrationColumns,
        res => {
          this.headList = res.data.content;
        }
      );
    },
    btnShow(btn) {
      if(btn == '新增' || '异地火化') return true;
      // if(btn == '附件上传') return true;
      if(this.currentRow){
        if(btn == '附件上传' || btn == '附件详情'){
          return true
        }
      }
      if(btn == '操作历史' && this.currentRow) return true;
      if (!this.currentRow) return false;
      if(this.currentRow.JPMSTATUS == "A"){
        if(btn == '提交' || btn == '修改' || btn == '删除'){
          return true;
        }
      };
      if(this.currentRow.JPMSTATUS == "B"){
        if(btn == '取消提交' || btn == '审核'){
          return true;
        }
      };
      if(this.currentRow.JPMSTATUS == "C"){
        if(btn == '取消审核' || btn == '变更' || btn == '审核修改' || btn == '地址修改'){
          return true;
        }
      };
      if(this.currentRow.JPMSTATUS == "G"){
        if(btn == '审核'){
          return true;
        }
      };
      if(btn == '打印死亡证明'){
        return true
      };

      // if(btn == '提交') return true;
      // if(btn == '办结') return true;
      // if(btn == '详情') return true;
      
      // if(btn == '修改' && this.currentRow) return true;
      // if(btn == '删除' && this.currentRow) return true;
      // if(btn == '审核' && this.currentRow) return true;
      // if(btn == '取消审核' && this.currentRow) return true;
      // if(btn == '取消提交' && this.currentRow) return true;
    },
    //功能操作
    operate(order) {
      this.order = order;
      this.dataRepeat();
      switch (this.order) {
        case "新增":
          this.$refs.simpleReg.open(this.order);
          break;
        case "异地火化":
          this.$refs.simpleReg.open(this.order);
          break;
        case "修改":
          this.$refs.simpleReg.open(this.order,this.currentRow.JPMID);
          break;
        case "详情":
          this.$refs.simpleReginfo.open(this.order,this.currentRow.JPMID);
          break;
        case "审核":
          this.$refs.simpleReg.open(this.order,this.currentRow.JPMID);
          break;
        case "取消审核":
          this.cancelExamine();
          break;
        case "提交":
          this.submits();
          break;
        case "取消提交":
          this.nosubmits();
          break;
        case "删除":
          this.dataDelete();
          break;
        case "附件上传":
          this.$refs.Upload.operate(this.order,this.currentRow.JPMID,this.currentRow.JPMSTATUS);
          break;
        case "附件详情":
          this.$refs.UploadInfo.operate('附件上传',this.currentRow.JPMID);
          break;
        case "变更":
          this.$refs.simpleReg.open('变更',this.currentRow.JPMID);
          break;
        case "审核修改":
          this.$refs.simpleReg.open('审核修改',this.currentRow.JPMID);
          break;
        case "地址修改":
          this.$refs.simpleReg.open('地址修改',this.currentRow.JPMID);
          break;
        case "打印死亡证明":
          this.$refs.printPdf.open(this.order, this.currentRow.JPMID);
          break;
        case "操作历史":
          this.$refs.OperationHistory.open('操作历史',this.currentRow.JPMID);
        default:
      }
    },
    // imgprint(){
    //   this.$refs.simpleReg.open('1');
    // },
    //提交
    submits(){
      this.$confirm("是否提交该数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
        }).then(callback => 
         {
            var data = {
              JPMID: this.currentRow.JPMID
            };
            apiBase.DoService(data, apiBase.getApiAdress().JointRegistration.Submit, res => {
              setTimeout(() => {
                this.getData();
              },1000)
            });
          });
    },

    //取消提交
    nosubmits(){
      this.$confirm("是否取消提交该数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
        }).then(callback =>
         {
            var data = {
              JPMID: this.currentRow.JPMID
            };
            apiBase.DoService(data, apiBase.getApiAdress().JointRegistration.CancelSubmit, res => {
              this.getData();
            });
          });
    },


    //登记删除
    dataDelete() {
       this.$confirm("是否删除该数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
        }).then(callback => 
         {
            var data = {
              JPMID: this.currentRow.JPMID
            };
            apiBase.DoService(data, apiBase.getApiAdress().JointRegistration.Delete, res => {
              this.getData();
            });
          });
    },
      //取消审核
    cancelExamine() {
       this.$confirm("确定取消审核吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
        }).then(callback => 
         {
            var data = {
              JPMID: this.currentRow.JPMID
            };
            apiBase.DoService(data, apiBase.getApiAdress().JointRegistration.CancelVerify, res => {
              this.getData();
            });
          });
    },
    //一键删除
   
    //查询条件重置
    btnRepeat() {
      // Object.assign(this.$data.selectData, this.$options.data().selectData);
      this.selectDataEixend.JPMCARDNO = null;
      // this.selectDataEixend.JpmCremationdateEquals = null;
      this.selectDataEixend.JPMNAME = null;
      // this.selectDataEixend.JpmDetailAddressEquals  = null;
      this.selectDataEixend.JpmStatusEquals = this.UnIchValue;
      this.getData();
    },
    //数据重置
    dataRepeat() {
      Object.assign(this.$data.regData, this.$options.data().regData);
      this.causList = [];
      this.ctyLists = [];
      this.regDataTime = null;
      this.cauinfo = [];
    },
  },
  mounted() {
    this.selectDataEixend.JpmStatusEquals = this.UnIchValue;
  },
  components: {
    dataTable,
    informationRegistrationMain,
    informationRegistrationInfo,
    printmodal,
    Appendixlisttwo,
    OperationHistory,
    Appendixlists
  },
   activated() {
    // this.getData();
  },
  created() {
    this.getColumns();
    // console.log(1);
    //  openidentitycard.connects();
    // this.getBussType();
    // this.getHousehold();
  },
  watch: {
   
  }
};
</script>
